/*
 * Copyright 2009 Original Author(s)
 * 
 * This file is part of Kommando
 * 
 * Kommando is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Kommando is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Kommando.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.kommando.skin;

import java.util.Collections;
import java.util.List;

import org.kommando.core.Kommando;
import org.kommando.core.KommandoWindow;
import org.kommando.core.util.Assert;

/**
 * @author Peter De Bruycker
 */
public class DefaultSkinManager implements SkinManager {

    private List<Skin> skins;

    private Skin current;
    private Kommando kommando;

    public DefaultSkinManager(Kommando kommando, List<Skin> skins) {
        Assert.argumentNotNull("kommando", kommando);
        Assert.argumentNotNull("skins", skins);

        this.kommando = kommando;
        this.skins = skins;
    }

    @Override
    public Skin getCurrent() {
        return current;
    }

    @Override
    public void setCurrent(Skin skin) {
        this.current = skin;
        KommandoWindow window = skin.createWindow();
        Assert.returnValueNotNull("Skin.createWindow", window);
        kommando.setKommandoWindow(window);
    }

    @Override
    public List<Skin> getSkins() {
        return Collections.unmodifiableList(skins);
    }

}
